/*toolSM stateMachine
Qiang.DAI
2025.08.30
YYYY.MM.DD
*/
/*this is a COMMON stateMachine File, means: 
State Transform Tab will not be created here.
each Peripheral creats its own State Transform Tab its own file.c
*/


#ifndef _TOOL_SM_H_
#define _TOOL_SM_H_

#include "main.h"
/***********************Programm Port**********************/
/*add all Peripheral's State & Event here*/
typedef enum{
STATE_null =1,
/*======User Button state======*/
/*--button driection State--*/
STATE_btnFtUp,
STATE_btnFtDown,
STATE_btnBkUp,
STATE_btnBkDown,
STATE_btnRtUp,
STATE_btnRtDown,
STATE_btnLfUp,
STATE_btnLfDown,
/*---button Aux State---*/	
STATE_btnAx1Up,
STATE_btnAx1Down,
STATE_btnAx2Up,
STATE_btnAx2Down,
STATE_btnAx3Up,
STATE_btnAx3Down,
STATE_btnAx4Up,
STATE_btnAx4Down,
/*======Nrf24L01 State======*/
STATE_nrfCommCheck,
STATE_nrfInit,
STATE_nrfModeSelec,
STATE_nrfTxMode,
//STATE_nrfTxWaitIRQ,
STATE_nrfRxMode,
//State_nrfRxWaitIRQ,
STATE_nrfErro,
STATE_nrfModeSet,

/*-----    -----*/
} SmState_t ;


typedef enum {	
EVENT_null = 1,
/*======User Button Event======*/
/*--driection button Event--*/	
EVENT_FtBtnUp,
EVENT_FtBtnDown,
EVENT_BkBtnUp,
EVENT_BkBtnDown,
EVENT_RtBtnUp,
EVENT_RtBtnDown,
EVENT_LfBtnUp,
EVENT_LfBtnDown,
/*---Aux Butten Event---*/		
EVENT_Ax1BtnUp,
EVENT_Ax1BtnDown,
EVENT_Ax2BtnUp,
EVENT_Ax2BtnDown,
EVENT_Ax3BtnUp,
EVENT_Ax3BtnDown,
EVENT_Ax4BtnUp,
EVENT_Ax4BtnDown,
/*======Nrf24L01 State======*/
EVENT_nrfInitSucc,
EVENT_nrfInitFail,
EVENT_nrfTXmodeRqst,
EVENT_nrfRXmodeRqst,
EVENT_nrfRxDmaFin_ISR,
EVENT_nrfTxDmaFin_ISR,
EVENT_Nrf_NIRQ_ISR,
/*-----    -----*/
} SmEvent_t;

/**********************End Programm Port********************/




/*CallBack Function Formate Typedef*/
typedef void(*Action_t)(SmEvent_t*);	

/*StateTrans Struct*/
typedef struct{
SmState_t mCurrentState;
SmEvent_t mEventTrigger;
SmState_t	mNextState;
Action_t actionMethod;	
}s_StateTransform_t;

/*stateMachine Struct*/
typedef struct{
SmState_t mState;
uint16_t mStateQty;  
s_StateTransform_t *k_trans_ptr;
} s_Statemachine_t;

void RunStatemchine(s_Statemachine_t *tmpSM_ptr, SmEvent_t tmpTriggerEvent);


#endif /*_TOOL_SM_H_*/

